﻿<%
Sa.Extends("checkAction")
'下载管理类
Class downAction
	
	'''添加下载分类
	Public Sub cadd()
		Sa.Show()
	End Sub
	
	'''修改下载分类
	Public Sub cedt()
		Sa.Dim("S_title")
		Sa.Dim("S_cid")
		Sa.Dim("S_px")
		Sa.Dim("S_id")
		Dim t_rs : Set t_rs = Db.GRD("Dclass","id=" & IfHas(G("id"), P("id")))
		If Not t_rs.Eof Then
			S_title = t_rs("name")
			S_cid = t_rs("cid")
			S_px = t_rs("px")
			S_id = t_rs("id")
		Else
			Sa.ErrorE("未找到该记录")
		End If
		Db.C(t_rs)
	End Sub
	
	'''保存分类修改
	Public Sub csave()
		Dim t_res
		Select Case Lcase(P("action"))
		Case "add"
			t_res = Db.AR("Dclass", Array("name:"&P("title"), "cid:"&P("cid"), "px:"&P("px")))
		Case "edt"
			t_res = Db.UR("Dclass", "id="&P("id"), Array("name:"&P("title"), "cid:"&P("cid"), "px:"&P("px")))
		Case "del"
			'批量删
			t_res = Db.DR("Dclass", "id:" & P("id"))  
		Case Else
			Sa.JumpUrl = "/?g=admin&m=down&a=clist"
			Sa.ErrorE("不允许的操作类型!")
		End Select
		If t_res Then
			Sa.JumpUrl = "/?g=admin&m=down&a=clist"
			Sa.Success("操作成功!")
		Else
			Sa.Error("操作失败")
		End If
	End Sub
	
	'''新闻分类列表
	Public Sub clist()
		Sa.Use("Pager")
		Pager.ShowPageNowA = True
		Pager.PageNow = G(Pager.PageVar&":n:1")
		Call Pager.AddLinkPara("g", "admin")
		Call Pager.AddLinkPara("m", "down")
		Call Pager.AddLinkPara("a", "clist")
		Pager.AddNOtherTaginfo("class=""current""")
		Sa.DimObject("crs")
		Set crs = Db.GR("Dclass","","id Asc")
		Pager.FormatRsByPage(crs)
	End Sub
	
	'''添加新闻
	Public Sub add()
		Sa.Dim("S_csql")
		S_csql = "Select * From Dclass Order By px Asc"
		Sa.Show()
	End Sub
	
	'''修改新闻
	Public Sub edt()
		Sa.DimObject("rs")
		Sa.Dim("S_csql")
		S_csql = "Select * From Dclass Order By px Asc"
		Set rs = Db.GRD("Download","id=" & IfHas(G("id"), P("id")))
		If rs.Eof Then
			Sa.ErrorE("未找到该记录")
		End If
	End Sub
	
	'''保存修改
	Public Sub save()
		Dim t_res
		Select Case Lcase(P("action"))
		Case "add"
			t_res = Db.AR("Download", Array("title:"&P("title"), "content:"&P("content"), "editor:"&Session("adminid"), "path:"&P("filepath"), "cid:"&P("cid"), "px:"&P("px")))
		Case "edt"
			'原文件的删除
			t_res = Db.UR("Download", "id="&P("id"), Array("title:"&P("title"), "content:"&P("content"), "editor:"&Session("adminid"), "path:"&P("filepath"), "cid:"&P("cid"), "px:"&P("px")))
		Case "del"
			'批量删
			'原文件的删除
			t_res = Db.DR("Download", "id:" & P("id"))  
		Case Else
			Sa.JumpUrl = "/?g=admin&m=down&a=list"
			Sa.ErrorE("不允许的操作类型!")
		End Select
		If t_res Then
			Sa.JumpUrl = "/?g=admin&m=down&a=list"
			Sa.Success("操作成功!")
		Else
			Sa.Error("操作失败")
		End If
	End Sub
	
	'''下载列表
	Public Sub list()
		Sa.Use("Pager")
		Pager.ShowPageNowA = True
		Pager.PageNow = G(Pager.PageVar&":n:1")
		Call Pager.AddLinkPara("g", "admin")
		Call Pager.AddLinkPara("m", "down")
		Call Pager.AddLinkPara("a", "list")
		Pager.AddNOtherTaginfo("class=""current""")
		Sa.DimObject("rs")
		Set rs = Db.GR("Download","","px Desc, id Desc")
		Pager.FormatRsByPage(rs)
	End Sub
	
End Class
%>